<?php

namespace app\admin\model;

use think\Model;


class Clock extends Model
{
    // 表名
    protected $table = 'clock';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';


    public function user()
    {
        return $this->belongsTo('app\admin\model\User','user_id','id')->field('id,username,nickname');
    }

    public function start()
    {
        return $this->belongsTo('app\admin\model\ClockLog','id','clock_id')->where('type',1);
    }

    public function end()
    {
        return $this->belongsTo('app\admin\model\ClockLog','id','clock_id')->where('type',2);
    }
}
